home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performSetKeyframeCharacter. < prev    next >
Encoding:
Text File  |  2003-07-17  |  5.6 KB  |  244 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Oct 20, 1998
  22. //  Author:         mt
  23. //
  24. //  Description:
  25. //      This script is the option box dialog for setting keyframes on characters.
  26. //
  27. //  Input Arguments:
  28. //      None.
  29. //
  30. //  Return Value:
  31. //      None.
  32. //
  33.  
  34. proc setOptionVars (int $forceFactorySettings)
  35. {
  36.     if( $forceFactorySettings || !`optionVar -exists setKeyframePrompt` ) {
  37.         optionVar -intValue setKeyframePrompt 0;
  38.     }
  39. }
  40.  
  41. global proc setKeyframeCharacterSetup (string $parent, int $forceFactorySettings)
  42. {
  43.     // Retrieve the option settings
  44.     //
  45.     setOptionVars( $forceFactorySettings );
  46.  
  47.     setParent $parent;
  48.  
  49.     if( `optionVar -query setKeyframePrompt` == 1 ) {
  50.         radioButtonGrp -e -select 2 setKeyframePrompt;
  51.     } else {
  52.         radioButtonGrp -e -select 1 setKeyframePrompt;
  53.     }
  54. }
  55.  
  56. global proc setKeyframeCharacterCallback (string $parent, int $doIt)
  57. //
  58. // Description:
  59. //    Set the optionVar's from the control values, and then perform
  60. //    the command
  61. //
  62. {
  63.     setParent $parent;
  64.  
  65.     if (`radioButtonGrp -query -select setKeyframePrompt` == 2) {
  66.         optionVar -intValue setKeyframePrompt 1;
  67.     } else {
  68.         optionVar -intValue setKeyframePrompt 0;
  69.     }
  70.  
  71.     if ($doIt)
  72.     {
  73.         performSetKeyframeCharacter false;
  74.     }
  75. }
  76.  
  77.  
  78.  
  79. proc string setKeyframeCharacterWidgets( string $parent )
  80. {
  81.     setParent $parent;
  82.     
  83.     string $tabForm = `columnLayout -adjustableColumn true`;
  84.  
  85.     radioButtonGrp -numberOfRadioButtons 2
  86.         -label  "Set Keys at"
  87.         -label1 "Current Time" 
  88.         -label2 "Prompt"
  89.         setKeyframePrompt;
  90.  
  91.     return $tabForm;
  92. }
  93.  
  94. global proc setKeyframeCharacterOptions ()
  95. {
  96.     string $commandName = "setKeyframeCharacter";
  97.  
  98.     string $applyTitle = "Set Key";
  99.     
  100.     // Build the option box "methods"
  101.     //
  102.     string $callback = ($commandName + "Callback");
  103.     string $setup = ($commandName + "Setup");
  104.  
  105.     //    Get the option box.
  106.     //
  107.     //  The value returned is the name of the layout to be used as
  108.     //    the parent for the option box UI.
  109.     //
  110.     string $layout = getOptionBox();
  111.     setParent $layout;
  112.  
  113.     setOptionBoxCommandName($commandName);
  114.  
  115.     setUITemplate -pushTemplate DefaultTemplate;
  116.     waitCursor -state 1;
  117.     tabLayout -scr true -tv false;    // To get the scroll bars
  118.  
  119.     string $parent = `columnLayout -adjustableColumn 1`;
  120.  
  121.     setKeyframeCharacterWidgets $parent;
  122.  
  123.     waitCursor -state 0;
  124.     setUITemplate -popTemplate;
  125.  
  126.     //    'Apply' button.
  127.     //
  128.     string $applyBtn = getOptionBoxApplyBtn();
  129.     button -edit
  130.         -label $applyTitle
  131.         -command ($callback + " " + $parent + " " + 1)
  132.         $applyBtn;
  133.     dimWhen -false "SomethingSelected" $applyBtn;
  134.  
  135.     //    'Save' button.
  136.     //
  137.     string $saveBtn = getOptionBoxSaveBtn();
  138.     button -edit 
  139.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  140.         $saveBtn;
  141.  
  142.     //    'Reset' button.
  143.     //
  144.     string $resetBtn = getOptionBoxResetBtn();
  145.     button -edit 
  146.         -command ($setup + " " + $parent + " " + 1)
  147.         $resetBtn;
  148.  
  149.     //    Set the option box title.
  150.     //
  151.     setOptionBoxTitle("Set Character Key Options");
  152.  
  153.     //    Set the current values of the option box.
  154.     //
  155.     eval (($setup + " " + $parent + " " + 0));    
  156.     
  157.     //    Show the option box.
  158.     //
  159.     showOptionBox();
  160. }
  161.  
  162.  
  163. //
  164. //  Procedure Name:
  165. //      assembleCmd
  166. //
  167. //  Description:
  168. //        Construct the command that will apply the option box values.
  169. //
  170. //  Input Arguments:
  171. //      None.
  172. //
  173. //  Return Value:
  174. //      None.
  175. //
  176. proc string assembleCmd()
  177. {
  178.     string $cmd;
  179.     int $breakdown = 0;
  180.  
  181.     setOptionVars(false);
  182.  
  183.     // doSetKeyframeCharacterArgList takes a string array 
  184.     //
  185.     string $cmd = "doSetKeyframeCharacterArgList 1 { " +
  186.                 "\"" + `optionVar -query setKeyframePrompt` + "\"" +
  187.                 ",\"" + $breakdown + "\"" +
  188.             " };";
  189.  
  190.     return $cmd;
  191. }
  192.  
  193. //
  194. //  Procedure Name:
  195. //      performSetKeyframeCharacter
  196. //
  197. //  Description:
  198. //        Perform the 'setKeyframe' command on the current characters 
  199. //      using the corresponding option values.  This procedure will 
  200. //      also show the option box window if necessary as well as 
  201. //      construct the command string that will invoke the 'setKeyframe' 
  202. //      command with the current option box values.
  203. //
  204. //  Input Arguments:
  205. //      0 - Execute the command.
  206. //      1 - Show the option box dialog.
  207. //      2 - Return the command.
  208. //
  209. //  Return Value:
  210. //      None.
  211. //
  212. global proc string
  213. performSetKeyframeCharacter (int $action)
  214. {
  215.     string $cmd = "";
  216.  
  217.     switch ($action) {
  218.  
  219.         //    Execute the command.
  220.         //
  221.         case 0:
  222.             //    Retrieve the option settings
  223.             //
  224.             setOptionVars(false);
  225.  
  226.             //    Get the command.
  227.             //
  228.             $cmd = `assembleCmd`;
  229.  
  230.             //    Execute the command with the option settings.
  231.             //
  232.             eval($cmd);
  233.  
  234.             break;
  235.  
  236.         //    Show the option box.
  237.         //
  238.         case 1:
  239.             setKeyframeCharacterOptions;
  240.             break;
  241.     }
  242.     return $cmd;
  243. }
  244.